package org.dubnation.auth.controller;

import org.dubnation.auth.domain.dto.LoginDTO;
import org.dubnation.auth.domain.vo.LoginVO;
import org.dubnation.auth.service.ILoginService;
import org.dubnation.base.util.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    /**
     * 管理员登录
     * @param loginDTO
     * @return
     */
    @PostMapping
    public AjaxResult login(@RequestBody @Valid LoginDTO loginDTO) {
        LoginVO loginVO = loginService.login(loginDTO);
        return AjaxResult.me().setData(loginVO);
    }
}
